home *** CD-ROM | disk | FTP | other *** search
- Path: news.hi.net!anjo!amcleod
- Distribution: world
- Newsgroups: comp.lang.c
- From: amcleod@anjo.hi.net (Angus Mcleod)
- X-Mailer: NetXpress 1.53
- Date: Mon, 08 Jan 1996 14:27:00 -0640
- Organization: The ANJO BBS
- Subject: Where am I going wrong?
- Message-ID: <414.1168.52@anjo.hi.net>
-
- I'm trying to create an OS/2 .DLL with functions I can call from REXX.
- Here is my super-simple trial source:
-
- #define INCL_REXXSAA
- #include <rexxsaa.h>
- #include <string.h>
-
- #define REXX_FAIL 40 /* raise Rexx error */
- #define REXX_OK 0 /* successful completion */
-
- /* declare exported REXX function */
- RexxFunctionHandler MyRexxFunc;
-
- /* a useful macro */
- #define MAKE_REXX_STR(t, s) { \
- strcpy((t)->strptr,(s));\
- (t)->strlength = strlen((s)); \
- }
-
- /* function: MyRexxFunc */
- ULONG MyRexxFunc(CHAR *name, ULONG numargs, RXSTRING args[],
- CHAR *queuename, RXSTRING *retstr) {
-
- char str[256] = "SUCCESS"; /* dummy result */
-
- MAKE_REXX_STR(retstr, str); /* pass back result */
- return REXX_OK; /* no error on call */
- }
-
-
- Couldn't be simpler, I'd have thought! I compile this, link the REXX.LIB
- and end up with MYRXDLL.DLL on the disk. Here's the output from the Watcom
- IDE Log.
-
- cd e:\watcom\hw
- wmake -f e:\watcom\hw\myrxdll.mk -h -e e:\watcom\hw\myrxdll.dll
- wcc386 myrxdll.c -i=F:\h;F:\h\os2 -w4 -e25 -zq -otexan -d2 -bd -5r -bt=os2 -mf
- wlink d all SYS os2v2 dll op m op maxe=25 op q op symf op one @myrxdll.lk1
- wlib -n -b myrxdll.lib +myrxdll.dll
- WATCOM Library Manager Version 10.5
- Copyright by WATCOM International Corp. 1988, 1995. All rights reserved.
- WATCOM is a trademark of WATCOM International Corp.
- Execution complete
-
- Now I run my TEST.CMD program to see if it works. Here it is:
-
- /* REXX! */
-
- rc = RxFuncAdd( 'MyRexxFunc', 'MyRxDll', 'MyRexxFunc' );
- say "RxFuncAdd returned " rc
-
- rc = RxFuncQuery( 'MyRexxFunc' );
- say "RxFuncQuery( 'MyRexxFunc' ); returned " rc
-
- rc = MyRexxFunc()
- say "MyRexxFunc() returned " rc
-
- And here is the result:
-
- [E:\WATCOM\HW]test
- RxFuncAdd returned 0
- RxFuncQuery( 'MyRexxFunc' ); returned 0
- 9 +++ rc = MyRexxFunc();
- REX0043: Error 43 running E:\watcom\hw\TEST.CMD, line 9: Routine not found
-
- [E:\WATCOM\HW]
-
- According to this, the function was successfully added (RxFuncAdd returned 0)
- and was found by RxFuncQuery (which also returned 0). Yet, line #9 halts with
- error 43.
-
- So where am I going wrong? The DLL appeared to compile, and my function even
- appeared to be added OK by RxFuncAdd, but...
-
- Oh yes - just to make matters easier, if I try to re-compile the source,
- I'm told the .DLL is in use and I get denied access. Example:
-
- [E:\WATCOM\HW]del *.dll
- E:\watcom\hw\MYRXDLL.DLL
- SYS0032: The process cannot access the file because it is being used
- by another process.
-
- [E:\WATCOM\HW]help 32
-
- SYS0032: The process cannot access the file because it is being used
- by another process.
-
- EXPLANATION: The file is already being used by another process.
-
- ACTION: Retry the command later.
-
- Surely I don't have to re-boot the machine in order to free up access to
- the .DLL so I can recompile it?
- .- -. .--- --- .- -. .--- --- .- -. .--- --- .- -. .--- ---
- Internet: amcleod@anjo.hi.net (Angus Mcleod)
- Origin: The ANJO BBS
-